1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
| public class Main implements HtwMessageReceiver { private static HuntTheWumpus game; private static int hitPoints = 10; private static final List<String> caverns = new ArrayList<>(); private static final String[] environments = new String[]{ "bright", "humid", "dry", "creepy", "ugly", "foggy", "hot", "cold", "drafty", "dreadful" }; private static final String[] shapes = new String[] { "round", "square", "oval", "irregular", "long", "craggy", "rough", "tall", "narrow" };
...
public static void main(String[] args) throws IOException { game = HtwFactory.makeGame("htw.game.HuntTheWumpusFacade", new Main()); createMap(); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); game.makeRestCommand().execute(); while (true) { System.out.println(game.getPlayerCavern()); System.out.println("Health: " + hitPoints + " arrows: " + game.getQuiver()); HuntTheWumpus.Command c = game.makeRestCommand(); System.out.println(">"); String command = br.readLine(); if (command.equalsIgnoreCase("e")) c = game.makeMoveCommand(EAST); else if (command.equalsIgnoreCase("w")) c = game.makeMoveCommand(WEST); else if (command.equalsIgnoreCase("n")) c = game.makeMoveCommand(NORTH); else if (command.equalsIgnoreCase("s")) c = game.makeMoveCommand(SOUTH); else if (command.equalsIgnoreCase("r")) c = game.makeRestCommand(); else if (command.equalsIgnoreCase("sw")) c = game.makeShootCommand(WEST); else if (command.equalsIgnoreCase("se")) c = game.makeShootCommand(EAST); else if (command.equalsIgnoreCase("sn")) c = game.makeShootCommand(NORTH); else if (command.equalsIgnoreCase("ss")) c = game.makeShootCommand(SOUTH); else if (command.equalsIgnoreCase("q")) return;
c.execute(); } } }
|